
#ifndef   __SYS_CLOCK_H_
#define   __SYS_CLOCK_H_


extern near bit Time_1ms;
extern near bit Time_2ms;
extern near bit Time_10ms;
extern near bit Time_100ms;
extern near bit Time_500ms;
extern near bit Time_1000ms;
extern near bit Time_5000ms;


/* 
	===== TIMER0; reg T1CON =====
	bit 2-0 T0PS<2:0>: Timer0 Prescaler Select bits
	111 = 1:256 prescale value
	110 = 1:128 prescale value
	101 = 1:64 prescale value
	100 = 1:32 prescale value
	011 = 1:16 prescale value
	010 = 1:8 prescale value
	001 = 1:4 prescale value
	000 = 1:2 prescale value
 */

#define   DEV_FREQ						16000000UL
#define   TMR0_DIV						32 /* see T1CON, bits:0-2 */
#define   TMR0_FREQ_PERIOD_uSEC		(1000000UL/(DEV_FREQ/4/TMR0_DIV)) 	/* 8uS */
#define   MSEC								*(1000UL/TMR0_FREQ_PERIOD_uSEC) 	/* 125*8uS=1mSec */
#define   SYS_CLOCK_PERIOD				(1MSEC)


void sys_clock_init ( void );

void sys_clock( void );

extern unsigned int sclock;

#define   SYS_CLOCK(ms)		((sclock<0xffff)&&!(sclock%ms))

#endif
